package net.oschina.app.v2.activity.news.fragment;

import net.oschina.app.v2.base.BaseFragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.tonlin.osc.happy.R;

public class ToolbarFragment extends BaseFragment {

	public interface OnActionClickListener {
		public void onActionClick(int action);
	}

	public final static int ACTION_WRITE = 1;

	private OnActionClickListener mActionListener;

	@Override
	public View onCreateView(LayoutInflater inflater,
			@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.v2_fragment_detail_tool_bar, container,
				false);

		initView(view);
		return view;
	}

	private void initView(View view) {
		view.findViewById(R.id.write_comment_layout).setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		final int id = v.getId();
		int action = -1;
		if (id == R.id.write_comment_layout) {
			action = ACTION_WRITE;
		}
		if (action != -1 && mActionListener != null) {
			mActionListener.onActionClick(action);
		}
	}

	public void setOnActionClickListener(OnActionClickListener lis) {
		mActionListener = lis;
	}
}
